package conf

import "github.com/spf13/viper"

type Conf struct {
	Mode   string `json:"mode"` // develop prod test 
	XueQiu struct {
		Token string `json:"token"`
	}
	MySql struct {
		Host     string `json:"host"`
		Port     int    `json:"port"`
		UserName string `json:"username"`
		Password string `json:"password"`
	}
}

func New() *Conf {
	viper.SetConfigName("config")
	viper.SetConfigType("yml")
	viper.AddConfigPath("./conf")
	err := viper.ReadInConfig()
	if err != nil {
		panic(err)
	}

	var conf Conf
	err = viper.Unmarshal(&conf)
	if err != nil {
		panic(err)
	}
	return &conf
}
